package rr18.rr181.rr181.rr18.plugin.list;

import com.kingdee.util.StringUtils;
import kd.bos.entity.filter.CompareTypeEnum;
import kd.bos.filter.FilterColumn;
import kd.bos.form.IPageCache;
import kd.bos.form.events.FilterContainerInitArgs;
import kd.bos.form.events.HyperLinkClickArgs;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.sdk.plugin.Plugin;

import java.util.Iterator;
import java.util.List;

/**
 * 标准单据列表插件
 */
public class DemoListPlugin01 extends AbstractListPlugin implements Plugin {

    @Override
    public void filterContainerInit(FilterContainerInitArgs args) {
        super.filterContainerInit(args);
        // 获取常用过滤字段集合对象
        List<FilterColumn> commonFilterColumns = args.getCommonFilterColumns();
        for (FilterColumn commonFilterColumn : commonFilterColumns){
            String fieldName = commonFilterColumn.getFieldName();
            // 判断如果是创建时间字段则设置默认值
            if(StringUtils.equals("biztime", fieldName)){
                // 本事件会多次触发，如果仅仅需要执行一次，则需要，需要增加标志变量，进行区分
                IPageCache pageCache = this.getView().getPageCache();
                // 获取页面缓存，并添加第一次执行标志标量
                if(pageCache.get("isfirst") == null){
                    commonFilterColumn.setDefaultValue(CompareTypeEnum.THISWEEK.getId());
                    pageCache.put("isfirst","true");
                }
            }
        }
    }

}